
package com.jf.cloud.api.user.feign;

import com.jf.cloud.api.user.bo.UidAndUserIdBO;
import com.jf.cloud.api.user.dto.MemberReqDTO;
import com.jf.cloud.api.user.dto.UserRegisterDTO;
import com.jf.cloud.api.user.vo.MemberContributeRespVO;
import com.jf.cloud.api.user.vo.MemberOverviewVO;
import com.jf.cloud.api.user.vo.UserApiVO;
import com.jf.cloud.common.feign.FeignInsideAuthConfig;
import com.jf.cloud.common.response.ServerResponseEntity;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import javax.validation.Valid;
import java.util.Date;
import java.util.List;

/**
 * 用户信息feign连接
 * @author zz
 * @date 2020/12/07
 */
@FeignClient(value = "jfcloud-user",contextId = "user")
public interface UserFeignClient {

    /**
     * 根据用户id列表，获取用户信息
     * @param userIds 用户id列表
     * @return 用户列表信息
     */
    @PostMapping(value = FeignInsideAuthConfig.FEIGN_URL_PREFIX + "/insider/user/getUserByUserIds")
    ServerResponseEntity<List<UserApiVO>> getUserByUserIds(@RequestBody List<Long> userIds);

    /**
     * 根据搜索条件查询用户列表
     * @param userApiVO
     * @return 用户列表信息
     */
    @GetMapping(value = FeignInsideAuthConfig.FEIGN_URL_PREFIX + "/insider/user/getUserByParam")
    ServerResponseEntity<List<UserApiVO>> getUserByParam(@RequestBody UserApiVO userApiVO);

    /**
     * 根据用户id获取用户详细信息
     * @param userId 用户id
     * @return 用户详细信息
     */
    @GetMapping(value = FeignInsideAuthConfig.FEIGN_URL_PREFIX + "/insider/user/getUserAndOpenIdsByUserId")
    ServerResponseEntity<UserApiVO> getUserAndOpenIdsByUserId(@RequestParam("userId") Long userId);

    /**
     * 获取用户数据
     * @param userId
     * @return
     */
    @GetMapping(value = FeignInsideAuthConfig.FEIGN_URL_PREFIX + "/user/getUserData")
    ServerResponseEntity<UserApiVO> getUserData(@RequestParam("userId") Long userId);

    /**
     * 跳过鉴权获取用户数据
     * @param userId 用户id
     * @return UserApiVO 用户信息
     */
    @GetMapping(value = FeignInsideAuthConfig.FEIGN_URL_PREFIX + "/insider/user/getUserData")
    ServerResponseEntity<UserApiVO> getInsiderUserData(@RequestParam("userId") Long userId);

    /**
     * 获取用户分析数据
     * @param param 筛选参数
     * @param startTime 开始时间
     * @param endTime 结束时间
     * @return 用户分析数据
     */
    @GetMapping(value = FeignInsideAuthConfig.FEIGN_URL_PREFIX + "/insider/user/getUserAnalysis")
    ServerResponseEntity<MemberOverviewVO> getUserAnalysis(@RequestBody MemberReqDTO param,
                                                           @RequestParam("startTime") Date startTime, @RequestParam("endTime")Date endTime);

    /**
     * 获取用户分析数据
     * @param param 筛选参数
     * @return 用户分析数据
     */
    @GetMapping(value = FeignInsideAuthConfig.FEIGN_URL_PREFIX + "/insider/user/getMemberAnalysisByParam")
    ServerResponseEntity<MemberOverviewVO> getMemberAnalysisByParam(@RequestBody MemberReqDTO param);

    /**
     * 获取用户分析数据
     * @param param 筛选参数
     * @return 用户分析数据
     */
    @GetMapping(value = FeignInsideAuthConfig.FEIGN_URL_PREFIX + "/insider/user/getMeetConditionsUserIds")
    ServerResponseEntity<List<Long>> getMeetConditionsUserIds(@RequestBody MemberReqDTO param);

    /**
     * --------------数据分析相关sql--------------
     * 根据条件参数，统计会员数量
     * @param param 参数
     * @return 数量
     */
    @GetMapping(value = FeignInsideAuthConfig.FEIGN_URL_PREFIX + "/insider/user/countPaidMemberByParam")
    ServerResponseEntity<MemberContributeRespVO> getMemberContributeByParam(@RequestBody MemberReqDTO param);

    /**
     * 筛选时间类的每一天注册的会员数数据
     * @param param 参数
     * @return 会员数数据
     */
    @GetMapping(value = FeignInsideAuthConfig.FEIGN_URL_PREFIX + "/insider/user/getMemberTrend")
    ServerResponseEntity<Integer> getMemberTrend(@RequestBody MemberReqDTO param);

    /**
     * 根据手机号码查询用户数量
     * @param mobile 手机号码
     * @return 用户数量
     */
    @GetMapping(value = FeignInsideAuthConfig.FEIGN_URL_PREFIX + "/insider/user/countUserByMobile")
    ServerResponseEntity<Integer> countUserByMobile(@RequestParam("mobile") String mobile);

    /**
     * 取消过期优惠券的绑定
     * @param couponIds 优惠券id列表
     * @return
     */
    @GetMapping(value = FeignInsideAuthConfig.FEIGN_URL_PREFIX + "/insider/user/cancelBindingCoupons")
    ServerResponseEntity<Void> cancelBindingCoupons(@RequestParam("couponIds") List<Long> couponIds);

    /**
     * 获取指定等级用户id
     * @param levelType 等级
     * @return
     */
    @GetMapping(value = FeignInsideAuthConfig.FEIGN_URL_PREFIX + "/insider/user/getUserIdListByLevel")
    ServerResponseEntity<List<Long>> getUserIdListByLevel(@RequestParam("levelType") Integer levelType);

    /**
     * 用户注册并绑定第三方账号
     * @param userRegisterDTO 注册信息
     * @return
     */
    @PostMapping(value = FeignInsideAuthConfig.FEIGN_INSIDER_URL_PREFIX + "/save")
    ServerResponseEntity<UidAndUserIdBO> save(@Valid @RequestBody UserRegisterDTO userRegisterDTO);
}
